<?php
// +----------------------------------------------------------------------
// | Longbing [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright Chengdu longbing Technology Co., Ltd.
// +----------------------------------------------------------------------
// | Website http://longbing.org/
// +----------------------------------------------------------------------
// | Sales manager: +86-13558882532 / +86-13330887474
// | Technical support: +86-15680635005
// | After-sale service: +86-17361005938
// +----------------------------------------------------------------------

declare(strict_types=1);

namespace app\im\info;

use app\card\model\CardCount;
use app\radar\model\RadarMessage;
use app\radar\model\RadarOrder;
use longbingcore\diy\BaseSubscribe;

/**
 * @author shuixian
 * @DataTime: 2019/12/11 16:23
 * Class Subscribe
 * @package app\ucenter\info
 */
class Subscribe extends BaseSubscribe
{
    /**
     * 相应个人中心工具菜单
     *
     * @return mixed
     * @author shuixian
     * @DataTime: 2019/12/12 11:24
     */
    public function onAddWorkStaffCenterMenu(){
        $toolsMenu= [

            "title" => '话术库管理',
          "icon" => 'iconhuashuku',
          "link" => '/admin/pages/speech/index',
          "linkType"=> '4',

        ];

        return [$toolsMenu];
    }


    /**
     * 员工 客户获取列表查询
     *
     * @param $data
     * @return array
     * @author shuixian
     * @DataTime: 2019/12/26 10:30
     */
    public function onStaffCustomerList($data)
    {
        //  聊天数量
        $map1         = [ [ 'user_id', '=', $data[ 'uid' ] ], [ 'target_id', '=', $data['to_uid']  ] ];
        $map2         = [ [ 'target_id', '=', $data[ 'uid' ] ], [ 'user_id', '=', $data['to_uid']  ] ];
        $messageCount = RadarMessage::whereOr( [ $map1, $map2 ] )->count();

        $msgData[ 'count' ] = $messageCount;
        $msgData[ 'title' ] = "聊天";

        //  通话数量
        $phoneCount = CardCount::where( [ [ 'user_id', '=', $data[ 'uid' ] ], [ 'to_uid', '=', $data['to_uid'] ],
                [ 'sign', '=', 'copy' ], [ 'type', 'in', [ 2, 3, 11 ] ] ]
        )->count();


        $phoneData[ 'count' ] = $phoneCount;
        $phoneData[ 'title' ] = "通话";

        return [$msgData , $phoneData];
    }

}